package com.feidee.bigdata.bloomfilterserv.service.impl;

import com.feidee.bigdata.bloomfilterserv.dao.IBloomFilterDao;
import com.feidee.bigdata.bloomfilterserv.model.CalcResultModel;
import com.feidee.bigdata.bloomfilterserv.model.RequestParamModel;
import com.feidee.bigdata.bloomfilterserv.service.IBloomFilterServService;
import com.feidee.bigdata.bloomfilterserv.util.ToolUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service("bloomFilterServService")
public class BloomFilterServService implements IBloomFilterServService {

	private Logger logger = LoggerFactory.getLogger(BloomFilterServService.class);

	@Autowired
	private IBloomFilterDao bloomFilterDao;

	@Override
	public CalcResultModel exclusiveCalc(RequestParamModel requestParamModel) {

		logger.info("布隆服务 机器标识:" + requestParamModel.getIpPrefix());
		Map<String, Boolean> blCalcRes = bloomFilterDao.judgeMetaIsInBF(requestParamModel);

		CalcResultModel calcResultModel = new CalcResultModel();
		calcResultModel.setCode("0");
		calcResultModel.setRequestId(ToolUtils.getUuid());
		calcResultModel.setMsg("Success");
		calcResultModel.setBlCalcRes(blCalcRes);

		return calcResultModel;

	}

}
